package com.topscore.uke.mvp.model;

import com.topscore.uke.entities.ActivitiesNewsData;
import com.topscore.uke.mvp.contractors.GetActivitiesContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import java.util.HashMap;
import java.util.Map;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 71468 on 2018/3/29.
 */

public class GetActivitiesModel implements GetActivitiesContractor,GetActivitiesContractor.Model {
    private CallBack mCallBack;

    public GetActivitiesModel(CallBack callBack) {
        this.mCallBack = callBack;
    }

    @Override
    public void getData(Map<String,Object> request) {
//        Map<String,Object> map = new HashMap<>();
////        loginName = "2279";
//        map.put("loginName",loginName);
        mService.getActivities(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<ActivitiesNewsData>>(mCallBack) {
                    @Override
                    public void onSuccess(BaseResponse<ActivitiesNewsData> response) {
                        mCallBack.onSuccess(response);
                    }
                });
    }
}
